*******************************************************************************************
*                                                                                         *
* The logic of ceasefires in civil war                                                    *
*                                                                                         *
* Govinda Clayton and Valerie Sticher                                                     *
*                                                                                         *
* This Version: February 17, 2021                                                         *
*                                                                                         *
*******************************************************************************************

use "/Users/govindaclayton/Desktop/ISQ_Replication_Data_CF.dta"

************************************PAPER ANALYSIS*********************************************

*****Table 2*****

stset duration1, failure (term_eithera) id(cf_id)

*Model 1-3
stcox prelim_cf defin_cf lag_bdths_1 if unilateral==0 & localcf==0 & exclude2 !=1   , nohr cl( ccode )
eststo model1
stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc lag_bdths_1  if localcf==0 & unilateral==0 & exclude2 !=1 , nohr cl( ccode )
eststo model2
stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo model3

*Model 4
stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1 & coh==0 , nohr cl( ccode )
eststo model4

esttab model1 model2 model3 model4, cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 

*Figure 2 (Graph 25 BD)
stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
stcurve, surv at1(prelim_cf =0 defin_cf=0 ) at2(prelim_cf=1 defin_cf=0 ) at3(prelim_cf=0 defin_cf=1) legend(size(small)) range (0 365) 

*Model 5-6

stset duration_1threshold, failure (term_either_1threshold) id(cf_id)

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude_1theshold !=1, nohr cl( ccode )
eststo model5

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude_1theshold !=1 & coh==0 , nohr cl( ccode )
eststo model6

esttab model5 model6 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 

* Figure 3 (Graph 1 BD)
stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude_1theshold !=1, nohr cl( ccode )
stcurve, surv at1(prelim_cf =0 defin_cf=0 ) at2(prelim_cf=1 defin_cf=0 ) at3(prelim_cf=0 defin_cf=1) legend(size(small)) range (0 365) 


*******Rerun data creation file with 100 BD as threshold. 
stset duration_100threshold, failure (term_either_100threshold) id(cf_id)

*Model 7-8
stset duration_100threshold, failure (term_either_100threshold) id(cf_id)

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude_100theshold !=1, nohr cl( ccode )
eststo model7

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude_100theshold !=1 & coh==0 , nohr cl( ccode )
eststo model8

esttab model7 model8 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 

*Figure Online Appenidx (OA) 1 (Graph 100 BD)
stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude_100theshold !=1, nohr cl( ccode )
stcurve, surv at1(prelim_cf =0 defin_cf=0 ) at2(prelim_cf=1 defin_cf=0 ) at3(prelim_cf=0 defin_cf=1) legend(size(small)) range (0 365) 



************ Open Matched Data 

use "/Users/govindaclayton/Desktop/ISQ_Matched_data.dta"

stset duration1, failure (term_eithera) id(cf_id)

*Model 9-10
stcox  prelim_cf defin_cf v2x_polyarchy lpop lrgdppc lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1 , nohr cl( ccode )
eststo modelm1

stcox  prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo modelm2

esttab modelm1 modelm2 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


*****Table 3******

use "/Users/govindaclayton/Desktop/ISQ_Replication_Data_CF.dta", replace


stset duration1, failure (term_eithera) id(cf_id)

*Models 11-15

stcox countprov3 defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo model11

stcox verification defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo model12

stcox violations defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo model13

stcox commission defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo model14

stcox  anyprov defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo model15

esttab model11 model12 model13 model14 model15 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


*****************************Robustness Checks*************************************


*Online Appendix Table 1: Not excluding local and unilateral
*Models OA1-OA4

stset duration1, failure (term_eithera) id(cf_id)


stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo modelOA1

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & exclude2 !=1 & coh==0 , nohr cl( ccode )
eststo modelOA2

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if local==0 & exclude2 !=1, nohr cl( ccode )
eststo modelOA3

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if local !=1 & coh==0 & exclude2 !=1 , nohr cl( ccode )
eststo modelOA4

esttab modelOA1 modelOA2 modelOA3 modelOA4 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 



*Online Appendix Table 2: Exlcuding those with fixed time and those longer than a year 
*Models OA5-OA8

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if  unilateral==0 &  local==0 & exclude2 !=1 & fixed1 !=1 , nohr cl( ccode )
eststo modelOA5

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0 & fixed1 !=1 & exclude2 !=1 , nohr cl( ccode )
eststo modelOA6

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1 & duration1<365 , nohr cl( ccode )
eststo modelOA7

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0 & duration1<365 & exclude2 !=1 , nohr cl( ccode )
eststo modelOA8

esttab modelOA5 modelOA6 modelOA7 modelOA8 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 



* Online Appendix Table 3: Testing alterniatve PA-X measures - transition to politics 

*Models OA9-OA12

stcox prelim_cf  polpartrans v2x_polyarchy lpop lrgdppc gov count count_dyads pko  lag_bdths_1    if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT31

stcox  polpartrans v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude2 !=1 , nohr cl( ccode )
eststo modelOAT32

stcox prelim_cf ssrddr2 v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo modelOAT33

stcox  ssrddr2  v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1 & coh==0 , nohr cl( ccode )
eststo modelOAT34

esttab modelOAT31 modelOAT32 modelOAT33 modelOAT34 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


* Online Appendix Table 4: Testing alterniatve monitoring with extension / Lagged IVs (prior CF)

*Models OA13-OA15

stcox  preliminary_CF_extra_mon defin_cf  v2x_polyarchy lpop lrgdppc gov count count_dyads pko  lag_bdths_123     if local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT41

stcox prelim_cf defin_cf  v2x_polyarchy lpop lrgdppc gov count count_dyads pko  defin_l prelim_l coh_l lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo modelOAT42

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko defin_l prelim_l coh_l  lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1 & coh==0 , nohr cl( ccode )
eststo modelOAT43

esttab modelOAT41 modelOAT42 modelOAT43  , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


*******Online Appendix Table 5: 

*Models OA16-OA17 (Duration in weeks)

stset durationweeks, failure (term_eithera) id(cf_id)
stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1, nohr cl( ccode )
eststo modelOAT51

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if localcf==0 & unilateral==0 & exclude2 !=1 & coh==0 , nohr cl( ccode )
eststo modelOAT52

esttab modelOAT51 modelOAT52  , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 

*Models OA18-OA19 (Only GED Events on specific day) 

stset duration_25threshold_gedday, failure (term_either_25_Gedday) id(cf_id)

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude_25gedday !=1  , nohr cl( ccode )
eststo modelOAT53

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude_25gedday !=1 , nohr cl( ccode )
eststo modelOAT54

esttab modelOAT53 modelOAT54 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


*Models OA20-OA21 (Only GED Events in specific month) 

stset duration_25threshold_GEDmon, failure (term_either_25threshold_GEDmon) id(cf_id)

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT53

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude2 !=1 , nohr cl( ccode )
eststo modelOAT54

esttab modelOAT53 modelOAT54 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


*******Online Appendix Table 6: Dependent Variable Specification

*Models OA22-OA23 (Only Violence for failure) 

stset duration1, failure (term_onlyvio) id(cf_id)

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT53

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude2 !=1 , nohr cl( ccode )
eststo modelOAT54

esttab modelOAT53 modelOAT54 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 



*Models OA24-OA25 (All forms of GED violence) 

  
stset duration_25threshold_allGED, failure (term_either_25_allged) id(cf_id)

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude_25allged !=1  , nohr cl( ccode )
eststo modelOAT53

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude_25allged !=1 , nohr cl( ccode )
eststo modelOAT54

esttab modelOAT53 modelOAT54 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 



*Online Appendix Table 7: Cluster Dyad and conflict ID rather than country 

*Models OA26-OA29

stset duration1, failure (term_eithera) id(cf_id)


stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1 , nohr cl(acd1 )
eststo modelOAT71

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0   & exclude2 !=1, nohr cl( acd1 )
eststo modelOAT72

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if  unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( dyad1 )
eststo modelOAT73

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude2 !=1 , nohr cl( dyad1 )
eststo modelOAT74

esttab modelOAT71 modelOAT72 modelOAT73 modelOAT74 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


* Online Appendix Table 8: Jacknife and Weibull

*Models OA30-OA33

jackknife: stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT71

jackknife: stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT72

streg prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr d(weibull)cl(ccode)
eststo modelOAT73

streg  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0 & exclude2 !=1  , nohr d(weibull)cl(ccode)
eststo modelOAT74

esttab modelOAT71 modelOAT72 modelOAT73 modelOAT74 , cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 



*Online Appendix Table 9: Alternative lag DVs

*Models OA34-OA39

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko  if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOA21

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko  if unilateral==0 & local !=1 & coh==0  & exclude2 !=1  , nohr cl( ccode )
eststo modelOA22

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_12 if  unilateral==0 & local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOA23

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_12 if unilateral==0 & local !=1 & coh==0  & exclude2 !=1 , nohr cl( ccode )
eststo modelOA24

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_123 if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOA25

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_123 if unilateral==0 & local !=1 & coh==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOA26

esttab modelOA21 modelOA22 modelOA23 modelOA24 modelOA25 modelOA26, cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


*Online Appendix Table 10: Interact monitoring and defin

*Model OA40

streg monitoring defin_cf monitoring##defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr d(weibull)cl(ccode)
eststo modelOA31

esttab modelOA31, cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


* Online Appendix Table 11: Additional Controls 

*Models OA41-OA46

*Diplomatic Missions

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads diplomatic pko lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT111

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads  diplomatic pko lag_bdths_1 if unilateral==0 & local !=1 & coh==0  & exclude2 !=1 , nohr cl( ccode )
eststo modelOAT112

*Total number of PKO forces 

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko troops   lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT113

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 troops   if unilateral==0 & local !=1 & coh==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT114

*UN Signatory 

stcox prelim_cf defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko imun lag_bdths_1 if unilateral==0 &  local==0 & exclude2 !=1  , nohr cl( ccode )
eststo modelOAT115

stcox  defin_cf v2x_polyarchy lpop lrgdppc gov count count_dyads pko lag_bdths_1 imun if unilateral==0 & local !=1 & coh==0  & exclude2 !=1 , nohr cl( ccode )
eststo modelOAT116

esttab modelOAT111 modelOAT112 modelOAT113 modelOAT114 modelOAT115 modelOAT116, cells(b(star fmt(3)) p(par fmt(2))) star(+ 0.10 * 0.05 ** 0.01) scalars("N_fail Conflict Terminations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared")  label 


